<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Comment;
use App\Article;

class CommentController extends Controller
{
    //
    public function store(Request $request){
        $article = Article::find($request->get('article_id'));
        $article->reply_total += 1;
        if(($article->save()) && (Comment::create($request->all()))){
            return redirect()->back();
        }else{
            return redirect()->back()->withInput()->withErrors('评论失败！');
        }
    }
}
